<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>三位数除两位数</title>
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/vue/2.2.4/vue.min.js"></script>
<style>
.t-item{
    padding-bottom:100px;
}
.center{
    text-align: center;
    padding-bottom:30px;
}
</style>
</head>
<body>
<div class="container" id="app">
    <h3 class="center">三位数除两位数</h3>
    <div class="row">
        <div class="col-xs-6 t-item" v-for="v in list">
            <span>{{v.a}}</span>
            <span> ÷ </span>
            <span>{{v.b}}</span>
            =
            <span v-show="show">{{v.r}}</span>
        </div>
    </div>
    <p class="center">
        <button class="btn btn-default" @click="show=!show">{{show?'隐藏':'显示'}}答案</button>
    </p>
</div>
</body>
</html>
<script src="./assets/fun.js"></script>
<script>
new Vue({
    el:"#app",
    data:{
        list:[],
        show:true,
    },
    created(){
        this.init();
    },
    methods:{
        init(){
            let list=[];
            for(let i=0;i<10;i++){
                let a=fun.rand(100,999);
                let b=fun.rand(10,99);
                let r=Math.floor(a/b);
                let ys=a%b;
                if(ys>0){
                    r=r+"......"+ys;
                }
                list.push({
                    a,
                    b,
                    r,
                })
            }
            this.list=list;
        }
    }
})
</script>